/***********************交通信息的路由***************************/
const express = require('express')
const pool = require('../pool.js')
const router = express.Router()
module.exports = router

//1.通过出发城市和到达城市查询交通信息的接口
//GET /check
//请求参数 start_city=上海&end_city=舟山
//测试地址：http://127.0.0.1:8080/v1/transport/check?start_city=上海&end_city=舟山
router.get('/check',(req,res,next)=>{
	let s = req.query.start_city
	let e = req.query.end_city
	let sql = 'select traffic_information from transport where start_city=? and end_city=?'
	pool.query(sql,[s,e],(err,result)=>{
		if(err){
			return next(err)
		}
		if(result.length>0){
			res.send({code:200,msg:'查询成功！',data:result})
		}else{
			res.send({code:201,msg:'查询失败！'})
		}
		
	})
})
